package java_thinking.unit_11._11_13;

import java.util.*;

/**
 * @Description : 验证Arrays.asList(i)会被打乱，要建立副本再操作shuffle
 * @author: cww
 * @DateTime: 2019-03-19 23:00
 */

public class ModifyingArraysAsList {
    public static void main(String[] args) {
        Random rand = new Random(47);
        Integer[] i = {1,2,3,4,5,6,7,8,9,10};
        List<Integer> list1 = new ArrayList<>(Arrays.asList(i));
        System.out.println("Before shuffling : "+list1);
        Collections.shuffle(list1,rand);
        System.out.println("After shuffling : "+list1);
        System.out.println("array: "+Arrays.toString(i));
        List<Integer> its = Arrays.asList(i);
        System.out.println("Before shuffling : "+its);
        Collections.shuffle(its,rand);
        System.out.println("After shuffling : "+its);
        System.out.println("array: "+Arrays.toString(i));
    }
}
